Skip to content

fix(ollama): generate unique toolUseId instead of reusing tool name#2053

Open
Ratansairohith wants to merge 1 commit intostrands-agents:mainfrom
Ratansairohith:fix/ollama-tool-use-id
Open

fix(ollama): generate unique toolUseId instead of reusing tool name#2053
Ratansairohith wants to merge 1 commit intostrands-agents:mainfrom
Ratansairohith:fix/ollama-tool-use-id

Conversation

@Ratansairohith
Copy link
Copy Markdown

Fixes #2050

Changes

src/strands/models/ollama.py:

  • Line 250: Generate a UUID for toolUseId instead of reusing the tool name. Prevents ID collisions when the same tool is called multiple times in one turn.
  • Line 128: Use content["toolUse"]["name"] instead of content["toolUse"]["toolUseId"] for the function name sent back to Ollama.

tests/strands/models/test_ollama.py:

  • Updated existing tests to reflect that toolUseId is no longer equal to the tool name
  • Added test_tool_use_id_is_unique_and_not_tool_name — verifies uniqueness across multiple calls
  • Added test_format_request_uses_tool_name_not_tool_use_id — verifies correct field is used for function name

Test plan

  • All 33 existing Ollama tests pass
  • 2 new tests verify the fix

- toolUseId was set to the tool name, causing ID collisions when the
  same tool is called multiple times in one turn
- format_request was using toolUseId instead of name for the function
  name sent back to Ollama

Fixes strands-agents#2050
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Ollama provider sets toolUseId to tool name instead of unique ID

1 participant